﻿<phone:PhoneApplicationPage 
    x:Class="tnet.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:advert="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"  
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"  
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Storyboard x:Name="PreloadAnimation" Completed="PreloadAnimation_Completed" >
                <DoubleAnimation Storyboard.TargetName="ThePivot" Storyboard.TargetProperty="Opacity" From="1" To="1" Duration="0:0:1" />
            </Storyboard>
        </Grid.Resources>
        <controls:Pivot x:Name="ThePivot" Title="Transhumanity.net" Foreground="White" Margin="0,-10,0,0" >
            <controls:Pivot.Background>
                <ImageBrush ImageSource="/Resources/PanoramaBackground.jpg"/>
            </controls:Pivot.Background>

            <controls:PivotItem Header="home">
                <Grid Margin="9,20,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="180" />
                        <ColumnDefinition Width="180" />
                        <ColumnDefinition Width="180" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="180" />
                        <RowDefinition Height="180" />
                        <RowDefinition Height="180" />
                        <RowDefinition Height="85" />
                    </Grid.RowDefinitions>

                    <!-- news blocks -->
                    <Grid Margin="5" >
                        <Rectangle Fill="#a4b33e" />
                        <TextBlock Margin="10,10,10,10" x:Name="TopNewsItem" FontSize="28" TextWrapping="Wrap" 
                                   Foreground="White"
                                   MouseLeftButtonUp="TopNewsItem_MouseLeftButtonUp" >
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu Background="#3d5906" >
                                    <toolkit:MenuItem x:Name="FacebookBox1" Header="share on facebook" Foreground="White" Click="FacebookBox_Click" /> 
                                    <toolkit:MenuItem x:Name="TwitterBox1"  Header="share on twitter" Foreground="White" Click="TwitterBox_Click" /> 
                                    <toolkit:MenuItem x:Name="FavBox1"      Header="add to favorites" Foreground="White" Click="Last3NewsFavorites_Click" /> 
                                    <toolkit:MenuItem x:Name="HomeBox1"     Header="pin to home" Foreground="White" Click="Last3NewsPin_Click" /> 
                                    <toolkit:MenuItem x:Name="EmailBox1"    Header="email" Foreground="White" Click="EmailNews_Click" /> 
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu></TextBlock>
                    </Grid>

                    <Grid Grid.Row="1" Grid.Column="1" Margin="5">
                        <Rectangle Fill="#a4b33e" />
                        <TextBlock Margin="10,10,10,10" x:Name="NextNewsTxt" FontSize="28" TextWrapping="Wrap" Foreground="White"
                                   MouseLeftButtonUp="TopNewsItem_MouseLeftButtonUp" >
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu Background="#3d5906" >
                                    <toolkit:MenuItem x:Name="FacebookBox2" Header="share on facebook" Foreground="White" Click="FacebookBox_Click" /> 
                                    <toolkit:MenuItem x:Name="TwitterBox2"  Header="share on twitter" Foreground="White" Click="TwitterBox_Click" /> 
                                    <toolkit:MenuItem x:Name="FavBox2"      Header="add to favorites" Foreground="White" Click="Last3NewsFavorites_Click" /> 
                                    <toolkit:MenuItem x:Name="HomeBox2"     Header="pin to home" Foreground="White" Click="Last3NewsPin_Click" /> 
                                    <toolkit:MenuItem x:Name="EmailBox2"    Header="email" Foreground="White" Click="EmailNews_Click" />  
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu></TextBlock>
                    </Grid>

                    <Grid Grid.Row="2" Margin="5">
                        <Rectangle Fill="#a4b33e" />
                        <TextBlock Margin="10,10,10,10" x:Name="ThirdItemTxt" FontSize="28" TextWrapping="Wrap" Foreground="White"
                                   MouseLeftButtonUp="TopNewsItem_MouseLeftButtonUp" >
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu Background="#3d5906" >
                                    <toolkit:MenuItem x:Name="FacebookBox3" Header="share on facebook" Foreground="White" Click="FacebookBox_Click" /> 
                                    <toolkit:MenuItem x:Name="TwitterBox3"  Header="share on twitter" Foreground="White" Click="TwitterBox_Click" /> 
                                    <toolkit:MenuItem x:Name="FavBox3"      Header="add to favorites" Foreground="White" Click="Last3NewsFavorites_Click" /> 
                                    <toolkit:MenuItem x:Name="HomeBox3"     Header="pin to home" Foreground="White" Click="Last3NewsPin_Click" /> 
                                    <toolkit:MenuItem x:Name="EmailBox3"    Header="email" Foreground="White" Click="EmailNews_Click" />  
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu></TextBlock>
                    </Grid>

                    <!-- block icons-->
                    <Image Source="/Resources/tileback.jpg" Grid.Row="2" Grid.Column="1" Margin="5" Width="180" Height="180" 
                        MouseLeftButtonUp="ImageURL_MouseLeftButtonUp" Tag="http://208.113.144.166/?page_id=2" />


                    <Grid Grid.Column="1" Width="180" Height="180" Margin="5">
                        <Image Source="/Resources/Tile.180.jpg" Width="180" Height="180" 
                           MouseLeftButtonUp="CallGlenn_MouseLeftButtonUp" />
                        <!--<Image Source="/Resources/phone.png" Grid.Column="1" Width="48" Height="48" Margin="130,-100,0,0" 
                           MouseLeftButtonUp="CallGlenn_MouseLeftButtonUp" />-->

                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu Name="MyContextMenu" Background="#3d5906" >
                                <toolkit:MenuItem Header="pin www.Transhumanity.net" Click="MenuItem_Click" Foreground="White" /> 
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>

                    </Grid>


                    <Image Source="/Resources/Icon.Daily.jpg" Width="175" Height="175" Grid.Column="0" Grid.Row="1" Margin="5"  
                        MouseLeftButtonUp="ImageURL_MouseLeftButtonUp" Tag="http://astore.amazon.com/pratoriate-20" />
                    
                    <!-- social media-->
                    <Image Source="/Resources/icon.facebook.jpg" Width="48" Height="48" Grid.Column="2" VerticalAlignment="Top" Margin="20,5,0,0"
                        MouseLeftButtonUp="ImageURL_MouseLeftButtonUp" Tag="https://www.facebook.com/pages/transhumanitynet/686157728086901" HorizontalAlignment="Left" />

                    <Image Source="/Resources/icon.linkedin.jpg" Width="48" Height="48" Grid.Column="2" VerticalAlignment="Bottom" Margin="20,0,0,30" HorizontalAlignment="Left" 
                        MouseLeftButtonUp="ImageURL_MouseLeftButtonUp" Tag="https://www.linkedin.com/groups/transhumanitynet-6747419" />

                    <Image Source="/Resources/icon.rss.jpg" Width="48" Height="48" Grid.Column="2" VerticalAlignment="Top" Grid.Row="1" Margin="20,30,0,0" 
                        MouseLeftButtonUp="ImageURL_MouseLeftButtonUp" Tag="http://208.113.144.166/?feed=rss2" HorizontalAlignment="Left" />

                    <Image Source="/Resources/icon.twitter.jpg" Width="48" Height="48" Grid.Column="2" VerticalAlignment="Bottom" Grid.Row="1"  
                        MouseLeftButtonUp="ImageURL_MouseLeftButtonUp" Tag="http://twitter.com/DavidJKelley" Margin="20,0,0,5" HorizontalAlignment="Left" />

               
                    <!--<advert:AdControl x:Name="AdvertControl" ApplicationId="d204dadc-2fb5-4fa2-b6d0-6d99e3ea95d0" 
                                      AdUnitId="82622" AdModel="Contextual" Grid.Row="3" Grid.ColumnSpan="3" RotationEnabled="True" 
                                      Width="480" Height="80" HorizontalAlignment="Left" 
                                      Margin="5,-5,0,0" UseLayoutRounding="False" d:LayoutRounding="Auto" d:LayoutOverrides="Height"  >
                    </advert:AdControl>-->
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="the news">
                <Grid >
                    <ListBox x:Name="BlogLstBx" Margin="0,10,0,0" IsEnabled="True" Foreground="White" 
                         HorizontalAlignment="Left" Width="410" Height="625" VerticalAlignment="Top"
                         ItemContainerStyle="{StaticResource ListBoxItemStyle1}" Tap="NewsRSS_Tap">
                        <ListBox.ItemTemplate >
                            <DataTemplate >
                                <Grid Height="70" Width="400" Margin="0,0,0,5" >
                                    <Rectangle Fill="#a4b33e" />
                                    <Rectangle Fill="#3d5906" Width="5" HorizontalAlignment="Left" Margin="5,0,0,0" />
                                    <StackPanel Orientation="Horizontal" Width="350" Margin="20,5,5,5" >
                                        <Image Source="{ Binding Path=Img}" Width="{ Binding Path=ImageWidth }" Height="70" Stretch="UniformToFill" />
                                        <TextBlock Text="{ Binding Path=Title}" Foreground="White" TextWrapping="Wrap" Margin="20,0,0,0" Width="270"  /> 
                                    </StackPanel>

                                    <toolkit:ContextMenuService.ContextMenu>
                                        <toolkit:ContextMenu Name="TheBlazeContextMenu" Background="#3d5906" >
                                            <toolkit:MenuItem Header="pin article to home" Click="TheBlazeMenuItem_Click"  Foreground="White" Tag="{ Binding Path=FreezeDried}" />
                                            <toolkit:MenuItem Header="share on facebook" Foreground="White" Click="FacebookBox_Click" Tag="{ Binding Path=FreezeDried}"  />
                                            <toolkit:MenuItem Header="share on twitter" Foreground="White" Click="TwitterBox_Click" Tag="{ Binding Path=FreezeDried}" />
                                            <toolkit:MenuItem Header="add to favorites" Click="AddToFavoritesMenuItem_Click"  Foreground="White" Tag="{ Binding Path=FreezeDried}" />
                                            <toolkit:MenuItem Header="email" Click="EmailNews_Click" Foreground="White"  Tag="{ Binding Path=FreezeDried}" />
                                        </toolkit:ContextMenu>
                                    </toolkit:ContextMenuService.ContextMenu>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PivotItem>

            <!--<controls:PivotItem Header="tweets" Visibility="Collapsed">
                <Grid >
                    <ListBox x:Name="TwitterLstBx" Margin="0,0,0,0" IsEnabled="True" Foreground="White" 
                        Tap="RSSListBox_Tap" HorizontalAlignment="Left" Width="410" Height="625" VerticalAlignment="Top"
                        ItemContainerStyle="{StaticResource ListBoxItemStyle1}"  >
                        <ListBox.ItemTemplate >
                            <DataTemplate >
                                <Grid Height="90" Width="400" Tag="{ Binding Path=Link}"  Margin="0,0,0,5" >
                                    <Rectangle Fill="White" Opacity=".3" />
                                    <Rectangle Fill="Black" Width="5" HorizontalAlignment="Left" Margin="5,0,0,0" />
                                    <TextBlock Text="{ Binding Path=Title}" Width="350" Foreground="Black" Margin="5,5,5,5" TextWrapping="Wrap" />

                                    <toolkit:ContextMenuService.ContextMenu>
                                        <toolkit:ContextMenu Name="TheBlazeContextMenu" Background="#365895" >
                                            <toolkit:MenuItem Header="share on facebook" Foreground="White" Click="TweeterFacebookBox_Click" Tag="{ Binding Path=FreezeDried}"  />
                                            <toolkit:MenuItem Header="retweet" Click="ReTwitterBox_Click"  Foreground="White" Tag="{ Binding Path=FreezeDried}" />
                                            <toolkit:MenuItem Header="email" Click="EmailNews_Click" Foreground="White"  Tag="{ Binding Path=FreezeDried}" />
                                        </toolkit:ContextMenu>
                                    </toolkit:ContextMenuService.ContextMenu>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PivotItem>-->
        </controls:Pivot>

        <Grid x:Name="PreloadProcessingGrid" >
            <Grid.Triggers>
                <EventTrigger RoutedEvent="Grid.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard Storyboard.TargetName="MyBall">
                                <DoubleAnimation Storyboard.TargetName="COne"   Storyboard.TargetProperty="Opacity" To="1" BeginTime="0:0:0"    Duration="0:0:3" RepeatBehavior="Forever"/>
                                <DoubleAnimation Storyboard.TargetName="CTwo"   Storyboard.TargetProperty="Opacity" To="1" BeginTime="0:0:.5"   Duration="0:0:3" RepeatBehavior="Forever"/>
                                <DoubleAnimation Storyboard.TargetName="CThree" Storyboard.TargetProperty="Opacity" To="1" BeginTime="0:0:1"    Duration="0:0:3" RepeatBehavior="Forever"/>
                                <DoubleAnimation Storyboard.TargetName="CFour"  Storyboard.TargetProperty="Opacity" To="1" BeginTime="0:0:1.5"  Duration="0:0:3" RepeatBehavior="Forever"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Grid.Triggers>
            <Image Source="/Resources/PanoramaBackground.jpg" Stretch="UniformToFill" />
            <TextBlock Text="loading data... " Style="{StaticResource PhoneTextTitle1Style}" FontSize="32" 
                       Margin="0,0,0,150" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <Canvas Width="100" Height="50" HorizontalAlignment="Center" 
                            VerticalAlignment="Center" Margin="0,0,0,0" CacheMode="BitmapCache" Background="Transparent" >
                <Ellipse x:Name="COne"      Fill="#c8ca5d" Height="10" Width="10" Opacity="0" />
                <Ellipse x:Name="CTwo"      Fill="#c8ca5d" Height="10" Width="10" Opacity="0" Canvas.Left="30" />
                <Ellipse x:Name="CThree"    Fill="#c8ca5d" Height="10" Width="10" Opacity="0" Canvas.Left="60" />
                <Ellipse x:Name="CFour"     Fill="#c8ca5d" Height="10" Width="10" Opacity="0" Canvas.Left="90" />
            </Canvas>
        </Grid>
       
    </Grid>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar x:Name="AppBarControls" IsVisible="False" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Resources/favs.png" Text="rate" x:Name="RateIcn" Click="RateIcn_Click" />
            <shell:ApplicationBarIconButton IconUri="/Resources/appbar.feature.email.rest.png" Text="email" x:Name="GlennIcn" Click="GlennIcn_Click" />
            <shell:ApplicationBar.MenuItems>
                <!--<shell:ApplicationBarMenuItem Text="technical help and admin" Click="help_Click"  />-->
                <shell:ApplicationBarMenuItem Text="favorites" Click="Favorites_Click"  />
                <shell:ApplicationBarMenuItem Text="about" Click="About_Click"  />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>